<template>
   <AyFormPage ref="ayFormPage" :button-list="buttonList">
    <AyCard title="${table.comment!}">
      <AyForm ref="projectDetail" :form-options="formOptions"></AyForm>
    </AyCard>
  </AyFormPage>
</template>

<script>
  import AyFormPage from '/@/components/AyUI/AyFormPage.vue';
  import AyForm from '/@/components/AyUI/AyForm.vue';
  import AyCard from '/@/components/AyUI/AyCard.vue';
  export default {
    name: '${entity}Add',
    components: {
      AyFormPage,
      AyForm,
      AyCard,
    },
    data() {

      return {
        formOptions: {
          data: {
            main: {
            <#list table.fields as field>
            ${field.propertyName}: '',
            </#list>
            }
          },
          items: [
             <#list table.fields as field>
               { field: 'main.${field.propertyName}', title: '${field.comment}', span: 12, itemRender: { name: 'VxeLabel' } },
              </#list>
              }
          ],
        },
      };
    },
    mounted() {
      this.formOptions.data.main.code = this.$route.query.code;
      this.Init();
    },
    methods: {
      async Init() {
        const res = await this.$api.${entity?lower_case}.Get${entity}tByCode({ code: this.formOptions.data.main.code });
        this.formOptions.data.main = res;
      }
    },
  };
</script>
